Commerce Search Sample Application
Commerce Search is an advanced Macromedia Flash-based sample application (see Figure 1) that takes advantage of many technologies Macromedia offers to allow you to access Amazon.com Web Services. The application demonstrates the use of the following:
- ColdFusion MX
- Macromedia Flash Remoting
- Components from all previous DevNet Resource Kits
- Object-oriented programming techniques and use of design patterns
- Access of SOAP web services

Figure 1. The Commerce Search sample application screen
Through this application, users can search for products from numerous Amazon.com catalogs, as well as add items to their shopping cart. It demonstrates persistence in storing data across user sessions and caching of data locally to prevent the recalling of searches that have already been performed. This is accomplished using the Local SharedObject feature available in Macromedia Flash, which lets you store complex data locally on the user's machine. This application uses a modified MVC pattern in its structure and follows all of the standard rules and practices for writing applications in Macromedia Flash MX.
Installing the Commerce Search Sample Application
Before setting up the application, make sure you have installed ColdFusion MX, along with the ColdFusion MX Updater. We will also need to install the Flash Remoting Components, and its updater. The ColdFusion MX Updater fixes a small error pertaining to how ColdFusion accesses AXIS web services and it is required to run the application.
Check out the links below to get what you need:
- ColdFusion MX download
- ColdFusion MX Updater
- Macromedia Flash Remoting MX Components
- Macromedia Flash Remoting MX Updater
Now navigate to your web root folder. If you used the default settings during installation, that folder should be C:\CFusionMX\wwwroot. Extract CommerceApplication.zip into your web root, making sure to maintain the Zip file's folder structure. This creates a folder called Commerce, which contains all of the files necessary to run the application.
If you look in the Commerce/components folder, you will find a file called csrequests.cfc. This file is the ColdFusion MX component that Macromedia Flash uses to access the Amazon.com Web Services. Through Flash Remoting, you will be able to access this component by using the service name "commerce.components.csrequests." As you can see, the service name follows the folder structure you created just previously.
Test the service to make sure you installed it correctly. Open Macromedia Flash MX and create a new document. In the first frame, on Layer 1, insert the following ActionScript code (note the line breaks added here to help readability):
#include "NetServices.as"
#include "NetDebug.as"
System.onStatus = function (error) {
for (var i in error) trace (i + " : " + error[i]);
}
var server = NetServices.createGatewayConnection("http://127.0.0.1/
flashservices/gateway");
var service = server.getService("commerce.components.csrequests",
this);
service.AmazonSearchRequest({method:"Asin",term:"B0000058HT,
B0000058HV,B0000058HV",type:"heavy"});
AmazonSearchRequest_Result = function() {
trace("Service Installed Correctly!");
}
Assuming that you installed ColdFusion on your local computer, go ahead and compile and run the movie. To view the Flash Remoting calls, open the NetConnection Debugger window (Window > NetConnection Debugger) in the Macromedia Flash IDE. This shows you the information being passed back and forth between Macromedia Flash and the remote service. If any errors occur, you will be able to learn more about the specific problems in this window.
If ColdFusion is not installed on your local computer, change the NetServices.createGatewayConnection method to point the application to where it can access the Flash Remoting gateway.
If you see "Service Installed Correctly!" in the output window, you are now ready to run Commerce Search.
Running the Commerce Search Sample Application
In order to run the Commerce Search sample application, open the classes/ApplicationClass.as file and edit the following two lines:
this.servicename = "commerce.components.csrequests"; this.gatewayurl = "http://127.0.0.1/flashservices/gateway";
The first line points to the path of the ColdFusion component. If you installed the application using the instructions above, you will not need to change this. The second variable specifies the path to the Flash Remoting gateway.
Once you have adjusted these variables, open CommerceSearch.fla file and run it.
What Next?
Now that you can run the application, feel free to take it apart! There are many possibilities for extending the application. You could add more search types, extend the shopping cart's functionality, or even add support for Amazon.com zShops. To learn more about Amazon.com Web Services, visit their site. Here you can sign up for your own developer token and start developing your own version of the Commerce Search sample application. To learn more about the other technologies used to develop Commerce Search, visit Macromedia DevNet.